<?php
/**
 * 
 */
namespace app\manage\controller\levelcoin;

use app\manage\controller\Base;

class Api extends Base
{

    public function config(){

        $data = model('level_coin_config')::data();
        return json(['code'=>1,'data'=>$data]);
    }

    /**
     * 按类型查询等级货币配置接口
     * @return [type] [description]
     */
    public function type_config(){
        $params = $this->request->only(['type']);
        $type = isset($params['type'])?$params['type']:'register';

        $data = model('level_coin_config')::levelCoinConfigByTypeWithLevel($type);
        return json(['code'=>1,'data'=>$data]);
    }

    /**
     * 按等级id与配置类型查询配置
     * @return [type] [description]
     */
    public function level_type_config(){
        $params = $this->request->only(['id','type']);

        $data = model('level_coin_config')::configByLevelType($params['id'],$params['type']);
        return json(['code'=>1,'data'=>$data]);
    }

    public function row(){
        $params = $this->request->only(['id','type']);
        $type = isset($params['type'])?$params['type']:'register';
        $data = model('level_coin_config')::data($type,$params['id']);
        return json(['code'=>1,'data'=>$data]);
    }
    
}